﻿app.factory('TodoFactory', function ($http, $q) {
   
    // get all todos
    var getAll = function () {
        var def = $q.defer();
        $http({
            method: 'GET',
            url: '/all'
        })
        .success(function (data) {
            def.resolve(data);
        })
        .error(function (data) {
            def.reject(data);
        })
        return def.promise;
    }


    // get all todos by ID
    var getById = function () {
        var def = $q.defer();
        $http({
            method: 'GET',
            url: '/allid'
        })
        .success(function (data) {
            def.resolve(data);
        })
        .error(function (data) {
            def.reject(data);
        })
        return def.promise;
    }


    // expose method

    return {
        getAll: getAll,
        getById: getById
    }


})